/*----------------------------------------------
| noka infobox v1.0 www.97521.com              |
| rebin 2014-01-15                             |
|---------------------------------------------*/
var ninfobox = Class.create({
    version: '1.0',
    initialize : function(rurl,cfg) {
    	this.eventids=cfg; //id
    	this.rurl = rurl;
    	this.postition={top:0,left:0};
    },
    show : function(){
    	this.EventInfoBox();
    },
    //--------------加载事件-------------------------------------------------------
    EventInfoBox : function(){
    	var self = this;
    	setTimeout(function(){
    		for(var i=0;i<self.eventids.length;i++){
        		try{
    	    		$(self.eventids[i]).showInfo=function(a,b){//显示信息
    	    			self.divMsg(this);
    	        		self.showInfo(a,b);
    	        	};
    	        	$(self.eventids[i]).showErro=function(a,b){//显示错误信息
    	        		self.divMsg(this);
    	        		self.showErro(a,b);
    	        	};
    	        	$(self.eventids[i]).showLoad=function(a){//显示等待信息
    	        		self.divMsg(this);
    	        		self.showLoad(a);
    	        	};
    	        	$(self.eventids[i]).closeInfo=function(){//关闭显示信息
    	        		self.postition.top=0;
    	        		self.postition.left=0;
    	        		self.closeInfo();
    	        	};
        		}catch(e){}
        	}
    	}, 500);
    },
  //--------------显示加载提示----------------------------------------------------
    showLoad : function(a){
    	var self = this;
    	if(typeof a=="undefined"){
	    	if(0==self.postition.left && 0==self.postition.top){
	    		NokaBox.box.show({html:'<img alt="" src="'+self.rurl+'/nokatag/tablegrid/images/mtg-loader.gif"/>load...',animate:1,fixed:false,close:false,mask:false,boxid:'success'});//显示等待消息
	    	}else{
	    		NokaBox.box.show({html:'<img alt="" src="'+self.rurl+'/nokatag/tablegrid/images/mtg-loader.gif"/>load...',animate:1,fixed:false,close:false,mask:false,boxid:'success',top:self.postition.top,left:self.postition.left});//显示等待消息
	    	}
    	}else{
    		if(0==self.postition.left && 0==self.postition.top){
	    		NokaBox.box.show({html:'<img alt="" src="'+self.rurl+'/nokatag/tablegrid/images/mtg-loader.gif"/>load...',animate:1,fixed:false,close:false,mask:false,autohide:a,boxid:'success'});//显示等待消息
	    	}else{
	    		NokaBox.box.show({html:'<img alt="" src="'+self.rurl+'/nokatag/tablegrid/images/mtg-loader.gif"/>load...',animate:1,fixed:false,close:false,mask:false,autohide:a,boxid:'success',top:self.postition.top,left:self.postition.left});//显示等待消息
	    	}
    	}
    },
    //--------------显示消息----------------------------------------------------
    showInfo : function(htmls,ahid){
    	var self = this;
    	if(typeof ahid=="undefined")
    		ahid=2;
    	if(0==self.postition.left && 0==self.postition.top){
    		NokaBox.box.show({html:htmls,fixed:false,close:false,mask:false,animate:1,autohide:ahid,boxid:'success'});//显示消息
    	}else{
    		NokaBox.box.show({html:htmls,fixed:false,close:false,mask:false,animate:1,autohide:ahid,boxid:'success',top:self.postition.top,left:self.postition.left});//显示消息
    	}
    },
    //--------------显示错了消息-------------------------------------------------
    showErro : function(htmls,ahid){
    	var self = this;
    	if(typeof ahid=="undefined")
    		ahid=2;
    	if(0==self.postition.left && 0==self.postition.top){
    		NokaBox.box.show({html:htmls,fixed:false,close:false,mask:false,animate:1,autohide:ahid,boxid:'error'});//显示消息
    	}else{
    		NokaBox.box.show({html:htmls,fixed:false,close:false,mask:false,animate:1,autohide:ahid,boxid:'error',top:self.postition.top,left:self.postition.left});//显示消息
    	}
    },
    //--------------关闭消息----------------------------------------------------
    closeInfo : function(){
    	NokaBox.box.hide();
    },
    //---------------div定位---------------------------------------------------
    divMsg : function(msgDiv){
    	var self = this;
    	try{
	    	if(typeof msgDiv!="undefined"){
	    		self.postition.top = msgDiv.positionedOffset().top+msgDiv.offsetHeight;
	    		self.postition.left =msgDiv.positionedOffset().left+msgDiv.offsetWidth;
	    	}
    	}catch(e){}
    }
});